package com.mzx.javase.thread.sleep;

import java.util.Random;

/**
 * 类描述：
 *
 * @ClassName SleepThread
 * @Description TODO
 * @Author 马子鑫
 * @Date 2022/8/1 17:15
 * @Version 1.0
 */
public class SleepThread extends Thread{
    @Override
    public void run() {
        String[] names = new String[]{"张三", "李四", "王五", "赵六"};
        for (int i = 3; i > 0; i--) {
            System.out.println("倒计时：" + i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
        int random = (int) (Math.random() * 4);
        System.out.println("抽中的人为：" + names[random]);
    }
}
